package com.drought.rained.presenter;

import com.drought.rained.BuildConfig;
import com.drought.rained.business.CustomConsumerLJ;
import com.drought.rained.business.ParamsFactoryLJ;
import com.drought.rained.cache.UserInfoLJ;
import com.drought.rained.mvpview.MineMvpViewLJ;
import com.drought.rained.response.PersonalInfoResponseLJ;
import com.drought.rained.response.UserInformationResponseLJ;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.functions.Consumer;

public class MinePresenterLJ extends BasePresenterLJ {
    private MineMvpViewLJ mvpView;

    public MinePresenterLJ(MineMvpViewLJ mvpView) {
        this.mvpView = mvpView;
    }

    public void getPersonInfo() {
        Map<String,Object>map=new HashMap<>();
        map.put("userUuid", UserInfoLJ.getShowUuid());
        toSubScribe(req.getPersonInfo(BuildConfig.channel, UserInfoLJ.getToken(), ParamsFactoryLJ.getCommonParams(map)), new CustomConsumerLJ<PersonalInfoResponseLJ>() {
            @Override
            public void call(PersonalInfoResponseLJ response) {
                mvpView.onGetDataNext(response);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                mvpView.onGetDataError(throwable);
            }
        });
    }

    public void getUserInformation() {
        Map<String,Object>map=new HashMap<>();
        map.put("userUuid", UserInfoLJ.getShowUuid());
        toSubScribe(req.getUserInformation(UserInfoLJ.getToken(), ParamsFactoryLJ.getCommonParams(map)), new CustomConsumerLJ<UserInformationResponseLJ>() {
            @Override
            public void call(UserInformationResponseLJ response) {
                mvpView.onGetDataNext(response);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                mvpView.onGetDataError(throwable);
            }
        });
    }
}
